#ifndef _ITEM_HPP_
#define	_ITEM_HPP_
/*******************************************************************************
 ** Name: item.hpp                                                            **
 ** Description: WorldObject-derived container objects                        **
 **                                                                           **
 ** Open Source Initiative (OSI) Approved License                             **
 **                                                                           **
 ** The contents of this file are subject to the terms of the                 **
 ** Common Development and Distribution License, Version 1.0 only             **
 ** (the "License").  You may not use this file except in compliance          **
 ** with the License.                                                         **
 **                                                                           **
 ** You can find a copy of the license in the LICENSE file within             **
 ** this distribution or at $WIKI/display/GOVT/License-software.              **
 ** Software distributed under the License is distributed on an "AS IS"       **
 ** basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.           **
 ** See the License for the specific language governing permissions           **
 ** and limitations under the License.                                        **
 **                                                                           **
 ** When distributing Covered Code, include this CDDL header in each          **
 ** file and include the License file at $GAME_DIR/LICENSE.                   **
 ** If applicable, add the following below this header, with the indicated    **
 ** fields enclosed by brackets "[]" replaced with your own identifying       **
 ** information: Portions Copyright [yyyy] [name of copyright owner]          **
 **                                                                           **
 ** Copyright (c) 2009-2011  Barry Gian James <gian@gamingods.net>            **
 ** All rights reserved.                                                      **
 ******************************************************************************/
// Portions (c) 2012 Open Design Strategies, LLC.
// Modified $Date: 2012-08-14 20:47:30 -0600 (Tue, 14 Aug 2012) $ by $Author: unknown $

#define Item_hpp_ID   "$Id: item.hpp 69068 2012-08-15 02:47:30Z unknown $"

#include "object.hpp"

enum class ItemCategory {
	Unknown,
	Technology, Support, Gadget, Tradecraft,
	Resource, Protective, Vehicle, Weapon
};
enum class ItemType {
	Unknown,
	Jewelry, Common, Consumable, Toxic, Decoration, Resource, Scratch,

	// derived types
	Container, Weapon, Device
};
extern const char * ItemTypeStr[];

// Item flags
#define ITEM_WEARABLE	0x00000001
#define ITEM_WEAR_HEAD	0x00000002
#define ITEM_WEAR_NECK 0x00000004
#define ITEM_WEAR_TORSO 0x00000008
#define ITEM_WEAR_BACK 0x000000010
#define ITEM_WEAR_RWRIST 0x00000020
#define ITEM_WEAR_LWRIST 0x00000040
#define ITEM_WEAR_LFINGER 0x00000080
#define ITEM_WEAR_RFINGER 0x00000100
#define ITEM_WEAR_LEGS 0x00000200
#define ITEM_WEAR_WAIST 0x00000400
#define ITEM_WEAR_FEET	 0x00000800
#define ITEM_WEAR_HANDS 0x00001000
#define ITEM_STACKABLE	 0x00002000
#define ITEM_DROPABLE   0x00004000
#define ITEM_SELLABLE	 0x00008000
#define ITEM_UNIQUE		0x00010000
#define ITEM_WIELDABLE	0x00020000

enum class ItemRestriction
{
	Unknown,
	None, Licensed, LawEnforcement, Government,
	Military, Banned
};

//! @class Item
//! @brief Base class for all "items" in the game except wearable, magic, weapons
#pragma db polymorphic pointer(boost::shared_ptr) table("items")
class Item : public WorldObject
{
public:
	SMART_PTR_DECL(Item);

	Item();
    Item(const std::string & n);
    Item(const Item& orig);
    virtual ~Item() { }

    // Getters
    const entity_t 	Creator() const { return _creator; }
    const ushort 	DmgSave() const { return _dmg_save; }
    const ushort 	Complexity() const { return _complexity; }
    const ushort 	Durability() const { return _durability; }
    const ushort 	DurabilityMax() const { return _durability_max; }
    const double 	DurabilityDecay() const { return _durability_decay; }
    const int 		StackAmount() const { return _stack_amount; }
    const int 		Cost() const { return _cost; }
    const ushort 	ErrorRange() const { return _error_range; }
    const ushort 	ThreatRange() const { return _threat_range; }
    const ItemCategory  Category() const { return _category; }
    const ItemRestriction  Restriction() const { return _restriction; }
    const unsigned int 	WearLocations() const { return _wear_locs; }
    const unsigned int 	WearLocation() const { return _wear_loc; }

    // Setters
    void	Creator(const entity_t c) { _creator = c; }
    void	DmgSave(const ushort s) { _dmg_save = s; }
    void	Complexity(const ushort c) { _complexity = c; }
    void	Durability(const ushort d) { _durability = d; }
    void	DurabilityMax(const ushort d) { _durability_max = d; }
    void	DurabilityDecay(const double d) { _durability_decay = d; }
    void	StackAmount(const int s) { _stack_amount = s; }
    void	Cost(const int c) { _cost = c; }
    void	ErrorRange(const ushort r) { _error_range = r; }
    void	ThreatRange(const ushort r) { _threat_range = r; }
    void	Category(const ItemCategory c) { _category = c; }
    void	Restriction(const ItemRestriction r) { _restriction = r; }
    void	WearLocations(const unsigned int wl) { _wear_locs = wl; }
    void	WearLocation(const unsigned int wl) { _wear_loc = wl; }

    bool		Dropable() { return Flags() & ITEM_DROPABLE; }
    bool		Stackable() { return Flags() & ITEM_STACKABLE; }
    bool		Wearable() { return Flags() & ITEM_WEARABLE; }

protected:
    entity_t	_creator;
    ushort		_dmg_save;
    ushort		_complexity;
    ushort		_durability;
    ushort		_durability_max;
    double		_durability_decay;
    int			_stack_amount;
    int			_cost;
    ushort		_error_range;	// between 0 - error_range
    ushort		_threat_range;	// between threat_range - 20
    ItemCategory _category;
    ItemRestriction	_restriction;
    unsigned int	_wear_locs;	// places this item can be worn
    unsigned int _wear_loc;		// actual place its worn, if at all

};

//! @class Device
//! @brief A specific Item derivation for security/electronic devices
#pragma db object table("devices")
class Device : public Item
{
public:
	Device();
	Device(const Device &);

private:
	friend class odb::access;
	ushort		_pr;
	ushort		_disable_dc;
	ushort		_detect_dc;
	int			_xp;
};

#endif	/* _ITEM_HPP_ */

